From 778b651cc3c83880a793f1bea964f4387337671f Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Mon, 16 May 2005 09:49:48 +0000 Subject: [PATCH] bitkeeper revision 1.1413 (42886cbcgOQRttqbKGwhoGUdvq0jbg) Fix the watchdog disable/enable interface. This cleans up common code somewhat. Signed-off-by: Keir Fraser --- xen/arch/ia64/xenmisc.c | 2 -- xen/arch/x86/cdb.c | 6 ++---- xen/arch/x86/domain.c | 2 +- xen/arch/x86/nmi.c | 23 ++++++++++++++++++++++- xen/arch/x86/setup.c | 3 ++- xen/arch/x86/traps.c | 2 +- xen/arch/x86/x86_32/traps.c | 3 +-- xen/arch/x86/x86_64/traps.c | 3 +-- xen/common/page_alloc.c | 7 +++---- xen/drivers/char/console.c | 8 +++----- xen/include/asm-ia64/config.h | 4 ++-- xen/include/asm-x86/apic.h | 5 +++-- 12 files changed, 41 insertions(+), 27 deletions(-) diff --git a/xen/arch/ia64/xenmisc.c b/xen/arch/ia64/xenmisc.c index 85f0bddc69..15ed4af4ea 100644 --- a/xen/arch/ia64/xenmisc.c +++ b/xen/arch/ia64/xenmisc.c @@ -23,8 +23,6 @@ unsigned long wait_init_idle; int phys_proc_id[NR_CPUS]; unsigned long loops_per_jiffy = (1<<12); // from linux/init/main.c -unsigned int watchdog_on = 0; // from arch/x86/nmi.c ?!? - void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n"); } void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); } void ia64_mca_cpu_init(void *x) { } diff --git a/xen/arch/x86/cdb.c b/xen/arch/x86/cdb.c index 451ce46853..899493380f 100644 --- a/xen/arch/x86/cdb.c +++ b/xen/arch/x86/cdb.c @@ -327,7 +327,6 @@ __trap_to_cdb(struct cpu_user_regs *regs) static atomic_t xendbg_running = ATOMIC_INIT(1); static char recv_buf[4096]; unsigned flags; - unsigned old_watchdog; if (xdb_ctx.serhnd < 0) { dbg_printk("Debugger not ready yet.\n"); @@ -358,8 +357,7 @@ __trap_to_cdb(struct cpu_user_regs *regs) interrupts while we're here. */ local_irq_save(flags); - old_watchdog = watchdog_on; - watchdog_on = 0; + watchdog_disable(); /* Shouldn't really do this, but otherwise we stop for no obvious reason, which is Bad */ @@ -385,7 +383,7 @@ __trap_to_cdb(struct cpu_user_regs *regs) ASSERT(!local_irq_is_enabled()); } } - watchdog_on = old_watchdog; + watchdog_enable(); atomic_inc(&xendbg_running); local_irq_restore(flags); return 0; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 22fea7eb82..6e69cf32cd 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -186,7 +186,7 @@ void __attribute__((noreturn)) __machine_halt(void *unused) void machine_halt(void) { - watchdog_on = 0; + watchdog_disable(); smp_call_function(__machine_halt, NULL, 1, 0); __machine_halt(NULL); } diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index afdf8051bb..aef14645e4 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -28,7 +28,6 @@ #include unsigned int nmi_watchdog = NMI_NONE; -unsigned int watchdog_on = 0; static unsigned int nmi_hz = HZ; unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */ @@ -256,6 +255,28 @@ static unsigned int last_irq_sums [NR_CPUS], alert_counter [NR_CPUS]; +static spinlock_t watchdog_lock = SPIN_LOCK_UNLOCKED; +static unsigned int watchdog_disable_count = 1; +static unsigned int watchdog_on; + +void watchdog_disable(void) +{ + unsigned long flags; + spin_lock_irqsave(&watchdog_lock, flags); + if ( watchdog_disable_count++ == 0 ) + watchdog_on = 0; + spin_unlock_irqrestore(&watchdog_lock, flags); +} + +void watchdog_enable(void) +{ + unsigned long flags; + spin_lock_irqsave(&watchdog_lock, flags); + if ( --watchdog_disable_count == 0 ) + watchdog_on = 1; + spin_unlock_irqrestore(&watchdog_lock, flags); +} + void touch_nmi_watchdog (void) { int i; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c6a5f2c55b..cb75477f03 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -450,7 +450,8 @@ static void __init start_of_day(void) while ( wait_init_idle != 0 ) cpu_relax(); - watchdog_on = 1; + watchdog_enable(); + #ifdef __x86_64__ /* x86_32 uses low mappings when building DOM0. */ zap_low_mappings(); #endif diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index fc723bf998..d68539df88 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -199,7 +199,7 @@ asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs) "machine check", "simd error" }; - watchdog_on = 0; + watchdog_disable(); show_registers(regs); diff --git a/xen/arch/x86/x86_32/traps.c b/xen/arch/x86/x86_32/traps.c index 9f924831ef..4d7c94e1b9 100644 --- a/xen/arch/x86/x86_32/traps.c +++ b/xen/arch/x86/x86_32/traps.c @@ -111,8 +111,7 @@ asmlinkage void do_double_fault(void) struct tss_struct *tss = &doublefault_tss; unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1; - /* Disable the NMI watchdog. It's useless now. */ - watchdog_on = 0; + watchdog_disable(); console_force_unlock(); diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index d48ae32fde..853dd95a38 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -60,8 +60,7 @@ void show_page_walk(unsigned long addr) asmlinkage void double_fault(void); asmlinkage void do_double_fault(struct cpu_user_regs *regs) { - /* Disable the NMI watchdog. It's useless now. */ - watchdog_on = 0; + watchdog_disable(); console_force_unlock(); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 8669ac8a27..e37422f962 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -356,15 +356,13 @@ void scrub_heap_pages(void) unsigned long pfn, flags; printk("Scrubbing Free RAM: "); + watchdog_disable(); for ( pfn = 0; pfn < (bitmap_size * 8); pfn++ ) { - /* Every 100MB, print a progress dot and appease the watchdog. */ + /* Every 100MB, print a progress dot. */ if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 ) - { printk("."); - touch_nmi_watchdog(); - } /* Quick lock-free check. */ if ( allocated_in_map(pfn) ) @@ -383,6 +381,7 @@ void scrub_heap_pages(void) spin_unlock_irqrestore(&heap_lock, flags); } + watchdog_enable(); printk("done.\n"); } diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index c873901e7b..de598bc114 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -502,14 +502,12 @@ integer_param("debugtrace", debugtrace_kilobytes); void debugtrace_dump(void) { - int _watchdog_on = watchdog_on; unsigned long flags; if ( (debugtrace_bytes == 0) || !debugtrace_used ) return; - /* Watchdog can trigger if we print a really large buffer. */ - watchdog_on = 0; + watchdog_disable(); spin_lock_irqsave(&debugtrace_lock, flags); @@ -529,7 +527,7 @@ void debugtrace_dump(void) spin_unlock_irqrestore(&debugtrace_lock, flags); - watchdog_on = _watchdog_on; + watchdog_enable(); } void debugtrace_printk(const char *fmt, ...) @@ -635,7 +633,7 @@ void panic(const char *fmt, ...) __putstr("Reboot in five seconds...\n"); spin_unlock_irqrestore(&console_lock, flags); - watchdog_on = 0; + watchdog_disable(); mdelay(5000); machine_restart(0); } diff --git a/xen/include/asm-ia64/config.h b/xen/include/asm-ia64/config.h index 9b656e493b..df5aef0824 100644 --- a/xen/include/asm-ia64/config.h +++ b/xen/include/asm-ia64/config.h @@ -29,7 +29,8 @@ typedef int pid_t; #define FASTCALL(x) x // see linux/include/linux/linkage.h #define fastcall // " " -#define touch_nmi_watchdog() +#define watchdog_disable() ((void)0) +#define watchdog_enable() ((void)0) // from linux/include/linux/types.h #define CLEAR_BITMAP(name,bits) \ memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long)) @@ -261,7 +262,6 @@ struct screen_info { }; // these declarations got moved at some point, find a better place for them extern int opt_noht; extern int ht_per_core; -extern unsigned int watchdog_on; // xen/include/asm/config.h /****************************************************************************** diff --git a/xen/include/asm-x86/apic.h b/xen/include/asm-x86/apic.h index 73112359a5..dcced35f79 100644 --- a/xen/include/asm-x86/apic.h +++ b/xen/include/asm-x86/apic.h @@ -104,15 +104,16 @@ extern void release_lapic_nmi(void); extern void disable_timer_nmi_watchdog(void); extern void enable_timer_nmi_watchdog(void); extern void nmi_watchdog_tick (struct cpu_user_regs *regs); -extern void touch_nmi_watchdog(void); extern int APIC_init_uniprocessor (void); extern void disable_APIC_timer(void); extern void enable_APIC_timer(void); -extern unsigned int watchdog_on; extern int check_nmi_watchdog (void); extern void enable_NMI_through_LVT0 (void * dummy); +extern void watchdog_disable(void); +extern void watchdog_enable(void); + extern unsigned int nmi_watchdog; #define NMI_NONE 0 #define NMI_IO_APIC 1 -- 2.30.2